﻿.modal.fade(id="alertInputDlg", tabindex="-1", role="dialog", aria-labelledby="myModalLabel", aria-hidden="true")
	.modal-dialog
		.modal-content
			.modal-header
				.btn.btn-default.close(data-dismiss="modal", aria-hidden="true") &times;
				h4.modal-title(id="myModalLabel")
			.modal-body
				form		
			.modal-footer
				.btn.btn-default.ok 确认
				.btn.btn-default.cancel(data-dismiss="modal") 取消
script(type="text/javascript").
	//  显示输入对话框
	//	接受输入参数 title?:string,
	//				inp_ctls:array of objects, 需要生成的输入控件说明对象数组。对象属性{value:控件默认值，name:输入控件id,dom_type:输入控件类型，lable:输入控件前的提示lable}
	//				okOnclick:function 对话框ok按钮的点击事件。
	function showInputModal() {
		let title,require_var_arr,ok_func,
			input_componet_template = {
				clts_template:"<div class='form-group'><div class='lable'>@{it_lbl}#</div>@{input_ctl}#</div>",
				input_clt_template:{
					input:"<input id=@{it}# ,class='form-control' type='text' value=@{it_val}# >",
					textarea:"<textarea class='form-control' id=@{it}# >@{it_val}#</textarea>"
				}
			},
			its = "";
		if (arguments.length > 2) {
			title = arguments[0] || "请输入";
			require_var_arr = arguments[1] || [];
			ok_func = arguments[2];
		} else {
			title = "请输入";
			require_var_arr = arguments[0] || [];
			ok_func = arguments[1];
		}
		require_var_arr.forEach(function(v,i){
			if(typeof v == 'object'&& 'name' in v && 'lable' in v){
				let htm = input_componet_template.clts_template.replace(/@{it_lbl}#/g,v.lable),
					clt = input_componet_template.input_clt_template[v.dom_type||"input"].replace(/@{it_val}#/g,v.value||'');
				htm = htm.replace(/@{input_ctl}#/g,clt).replace(/@{it}#/g,v.name);
				its += htm;
			}			
		});
		$('#alertInputDlg').find(".modal-title").html(title);
		$('#alertInputDlg').find(".modal-body form").html(its);
		$('#alertInputDlg').find(".modal-footer div.btn.ok").off('click');
		if(typeof ok_func == 'function'){
			$('#alertInputDlg').find(".modal-footer div.btn.ok").click(ok_func);
		}
		$('#alertInputDlg').modal();
	}